<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import = "ass.beans.*"
	import = "ass.dao.support.*"
	import = "java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Movie Detail</title>
</head>
<body>
	<%
		MovieBean movieBean =null;
		ReviewDAOImpl reviewDAOImpl = new ReviewDAOImpl();
		List<ReviewBean> reviewBeanList= new ArrayList<ReviewBean>();
		if (request.getAttribute("movieBean") != null ) {
			movieBean = (MovieBean) request.getAttribute("movieBean");
		}else {
			MovieDAOImpl movieDAOImpl = new MovieDAOImpl();
			movieBean = (MovieBean)  movieDAOImpl.getMovie( Integer.parseInt((String)request.getAttribute("movieID")));
		}
		reviewBeanList = reviewDAOImpl.getReviewByMovie(movieBean.getMovie_id());
		
    %>
	<%@ include file="header.html"%>
	<%@ include file="userNavBar.html"%>
	<div align="center">
	<form action="Review" method="post" name="Review">
		
		<%= (String) request.getAttribute("reviewPosted") == null ? "":(String) request.getAttribute("reviewPosted") %>
		
		<table width="400" border="0">
			<tr>
				<td rowspan="6"><img src="img/poster1.jpg" width="144" height="151"></td>
				<td>&nbsp;</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>Title:</td>
				<td> <%= movieBean.getMovie_title() %></td>
			</tr>
			
			<tr>
				<td>&nbsp;</td>
				<td>Main Actor:</td>
				<td><%= movieBean.getMovie_actor() %></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>Synopsis: </td>
				<td><%= movieBean.getMovie_synopsis() %></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>Rating: </td>
				<td><%= movieBean.getMovie_rating() %></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td colspan="2">Click <a href="MovieDetail2?id=<%= movieBean.getMovie_id()%>">here</a> to book tickets.</td>
			</tr>

			</table>
			
			<br>
			<br>
			<table width="400" border="1">
			<tr>
				<tr><b>Review</b></tr>
				<tr>&nbsp;</tr>
			</tr>
			
			<% 
			if (reviewBeanList.isEmpty()) {
				out.print("<tr>");
				out.print("<td colspan='3'>no review yet</td>");
				out.print("</tr>");
			}else {
				for (ReviewBean x : reviewBeanList){
					out.print("<tr>");
					out.print("<td> nickname : "+x.getNickname()+"</td>");
					out.print("<td> date : "+x.getDate_added()+"</td>");
					out.print("<td> rating :"+x.getRating()+"</td>");
					out.print("</tr>");
					out.print("<tr>");
					out.print("<td colspan='3'>"+x.getReview()+"</td>");
					out.print("</tr>");
				}
			}
			
			%>
			
			</table>
			
			<br/>
			<br/>
			<br/>
			
			<input type="hidden" name="movieID" value="<%= movieBean.getMovie_id() %>">
			
			<table>
				
				<tr>
				<td>&nbsp;</td>
				<td>Nickname</td>
				<td><input type="text" name ="nickname">
				</td>
				</tr>
				
				<tr>
				<td>&nbsp;</td>
				<td>My Rating:</td>
				<td><label for="myrating"></label> <select name="myrating"
					id="myrating">
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
				</select>
				</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>My Review:</td>
					<td><label for="myreview"></label> <textarea name="myreview"
							id="myreview" cols="45" rows="5"></textarea>
					</td>
				</tr>
				<tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<td><input type="submit" name="button" id="button"
					value="Submit">
				</td>
				</tr>
		</table>
	</form>
	</div>


</body>
</html>